<?php 

class ProjectMenu extends CActiveRecord
{
	public $parentPath;

	/**
	* Returns the static model of the specified AR class.
	* @return Menu the static model class
	*/
	public static function model($className=__CLASS__)
		{
			return parent::model($className);
		}

	/**
	* @return string the associated database table name
	*/
	public function tableName()
		{
			return 'T_WellProject';
		}

	/**
	* @return array behaviors.
	*/
	public function behaviors()
		{
			return array(
								'TreeBehavior' => array('class' => 'ext.behaviors.XTreeBehaviors',
								'treeLabelMethod'=> 'getTreeLabel',
								'menuUrlMethod'=> 'getMenuUrl',
								),
							);
		}

	/**
	* @return array validation rules for model attributes.
	*/
	public function rules()
		{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
			return array(
								array('id, position', 'numerical', 'integerOnly'=>true),
								array('project_ID, position', 'numerical', 'integerOnly'=>true),
								array('well_ID, position', 'numerical', 'integerOnly'=>true),
								array('nameProject', 'length', 'max'=>256),
								array('nameWell', 'length', 'max'=>256),
							);
		}

	public function relations()
		{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
			return array(
								'parent' => array(self::BELONGS_TO, 'T_WellProject', 'project_id'),
								'children' => array(self::HAS_MANY, 'T_WellProject', 'well_id', 'order' => 'well_ID'),
								'childCount' => array(self::STAT, 'T_WellProject', 'well_id'),
							);
		}

	public function attributeLabels()
		{
			return array(
								/*'id' => Yii::t('ui', 'ID'),*/
								'project_id' => Yii::t('ui', 'project_id'),
								'well_id' => Yii::t('ui', 'well_id'),
								'nameProject' => Yii::t('ui', 'nameProject'),
								'nameWell' => Yii::t('ui', 'nameWell'),
							);
		}

	/**
	* @return string tree label
	*/
	public function getTreeLabel()
		{
			return $this->label;
		}


}

?>